package org.example.ioc.process;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * ClassName: MyHappyBeanProcessor
 * Package: org.example.ioc.process
 * Description: 自定义bean的后置处理器
 *              bean的后置处理器不是单独针对某一个bean生效，而是针对IOC容器中的所有bean生效
 *
 * @Author 王豪
 * @Create 2024/11/2 8:39
 * @Version 1.0
 */
public class MyHappyBeanProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("初始化之前：" + beanName + " = " + bean);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("初始化之后：" + beanName + " = " + bean);
        return bean;
    }
}
